package mouse;

import impsoft.painting.PaintJob;
import impsoft.scripting.ibot.structs.XY;

import java.awt.Graphics;
import java.awt.event.MouseEvent;

import paint.TimedComponent;

public class MouseTrack extends PaintJob implements TimedComponent {
	private long created = 0;
	private long totalTime = 100;
	protected XY location = null;
	protected MouseEvent event;

	public MouseTrack(XY location, MouseEvent event) {
		super();
		this.location = location;
		this.event = event;
		created = System.currentTimeMillis();
	}

	public XY getLocation() {
		return location;
	}

	@Override
	public boolean isUp() {
		return System.currentTimeMillis() - created > totalTime;
	}

	public double getPercentTimeLeft() {
		return (System.currentTimeMillis() - created) / totalTime;
	}

	public MouseEvent getEvent() {
		return event;
	}

	@Override
	public void paint(Graphics g) {

	}

	@Override
	public boolean timeUp() {
		return isUp();
	}

	@Override
	public long getExpiration() {
		return totalTime - (System.currentTimeMillis() - created);
	}

	@Override
	public boolean hasExpirationTime() {
		return true;
	}

	@Override
	public void setExpiration(long time) {
		totalTime = time;
	}
}
